﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Xml.Linq;
using EvoGame.Ceeforee.Helpers;
using EvoGame.Ceeforee.CivilizationPanels;

namespace EvoGame.Ceeforee
{
	public partial class MainWin
	{
		public Civilization selectedCiv;
		private CivPanel loadedPanel;

		public void LoadCivilizations()
		{
			civSelect.Items.Clear();			
			civSelect.Items.AddRange(civDB.GetCivNames().ToArray());
		}

		private void civSelect_SelectedIndexChanged(object sender, EventArgs e)
		{
			ComboBox s = (ComboBox)sender;
			int idx = s.SelectedIndex;
			selectedCiv = civDB.GetCiv(civDB.GetCivNames(true)[idx]);
			if (loadedPanel != null)
				loadedPanel.Update();
		}

		private void civOptions_After_Select(object sender, TreeViewEventArgs e)
		{
			loadedPanel = e.Node.Tag as CivPanel;
			if (loadedPanel != null)
			{
				this.civRightPane.Controls.Clear();
				this.civRightPane.Controls.Add(loadedPanel);
				loadedPanel.Dock = DockStyle.Fill;
				if (selectedCiv != null)
					loadedPanel.Update();
			}
		}
	}
}